/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.vijay.mvnbuilddownload;


import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 *
 * @author elangovanv
 */
/*
<metadata>
<groupId>com.dnb.dnbi.creditCommon</groupId>
<artifactId>dnbi-creditCommon-assembly</artifactId>
<version>9.0.8-SNAPSHOT</version>
<versioning>
<snapshot>
<timestamp>20101215.010239</timestamp>
<buildNumber>1</buildNumber>
</snapshot>
<lastUpdated>20101215010344</lastUpdated>
</versioning>
</metadata>
 */

public class MetadataVersioning {

    private MetadataVersioningSnapshot snapshotVersioning;

    private String lastUpdated;
    private String latest;
    private String release;
    private MetadataVersioniningReleasedVersions versions;

    private NodeList nodeList;

    public MetadataVersioning(NodeList nodeList) {
        this.nodeList=nodeList;
    }

    public void parse() {
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);

            if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("lastUpdated")) {
                this.lastUpdated=node.getTextContent();
            } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("latest")) {
                this.latest=node.getTextContent();
            } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("release")) {
                this.release=node.getTextContent();
            } else if (node.getNodeType() == Node.ELEMENT_NODE && ((Element) node).getTagName().equals("snapshot")) {
                this.snapshotVersioning=new MetadataVersioningSnapshot(((Element) node).getChildNodes());
                this.snapshotVersioning.parse();
            }
        }
    }

    public String getLastUpdated() {
        return lastUpdated;
    }

    public void setLastUpdated(String lastUpdated) {
        this.lastUpdated = lastUpdated;
    }

    public MetadataVersioningSnapshot getSnapshotVersioning() {
        return snapshotVersioning;
    }

    public void setSnapshotVersioning(MetadataVersioningSnapshot snapshotVersioning) {
        this.snapshotVersioning = snapshotVersioning;
    }

    public String toString() {
        return "MetadataVersioning{" + "snapshotVersioning=" + snapshotVersioning + "lastUpdated=" + lastUpdated + "latest=" + latest + "release=" + release + "versions=" + versions +  '}';
    }

    
}
